<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"D-5");
$currentPage = $_SERVER["PHP_SELF"];
mysql_select_db($database_con_gl, $con_gl);
$query_aset = "SELECT gl_aset.id, gl_aset.aset, gl_aset.qty, gl_aset.total, gl_aset.thn, gl_gol.golongan, gl_gol.jangka, gl_gol.bobot, gl_gol.jangka, gl_gol.bobot FROM gl_aset, gl_gol WHERE gl_gol.id = gl_aset.golID ORDER BY gl_gol.golongan, gl_aset.aset";
$aset = mysql_query($query_aset, $con_gl) or die(mysql_error());
$row_aset = mysql_fetch_assoc($aset);
$totalRows_aset = mysql_num_rows($aset);

if($_POST['tahun'] <>'') {
$tahun = $_POST['tahun'];
}else{ 
$tahun = date("Y");
}
$query_data = $query_aset;
include('include/widget_exportdata.php');
?>
<h1>Penyusutan Aset</h1>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" style="border-bottoms:solid 1px #E2EAC1;"> 
  <tr valign="top">
    <td align="right"><!--<form id="search" name="search" method="post" action="">
      <label></label>
      <label>Penyusutan Aset pada tahun : 
      <select name="tahun" id="tahun" style="width:90px;text-align:center;">
	  <?php //for($ii = $tahun-50;$ii<=$tahun+50;$ii++) { ?>
        <option value="<?php //echo $ii;?>" <?php //if($ii == $tahun) { ?>selected="selected"<?php //} ?>><?php //echo $ii;?></option>
	  <?php //} ?>
      </select>
      </label>
      <label>
        <input name="Search" type="submit" id="Search" value="Tampilkan" />
        </label>
    </form>-->    </td>
  </tr>
  <?php if($totalRows_aset > 0) { //if(isset($_POST['Search'])) { ?>
  	<?php //if($totalRows_aset > 0) { ?>
  <tr>
    <td ><table width="100%" border="0" cellspacing="0" cellpadding="5" class="datatable">
        <tr>
          <th align="center"><strong>ASET (Qty) </strong></th>
          <th width="15%" align="center"><strong>Golongan</strong></th>
          <th width="10%" align="center"><strong>Umur</strong></th>
          <th width="12%" align="center"><strong>Nilai Perolehan </strong></th>
          <th width="12%" align="center"><strong>Pe. / Bulan </strong></th>
          <th width="14%" align="center"><strong>Akm.Penyusutan </strong></th>
          <th width="14%" align="center"><strong>Nilai Buku </strong></th>
        </tr>
        <?php $totawl = 0; $totsusut = 0; $totas = 0; do { ?>
		<?php $jx = $tahun - $row_aset['thn']; $bz = $jx / $row_aset['jangka']; $pexc = explode(".",$bz);$bx = $pexc[0];?>
          <tr align="center" valign="top" bgcolor="#FFFFFF">
            <td align="left"><?php echo $row_aset['aset']; ?> (<?php echo $row_aset['qty']; ?>) </td>
            <td><?php echo $row_aset['golongan']; ?></td>
            <td><?php echo $row_aset['jangka']; ?> Tahun </td>
            <td align="right"><?php echo number_format($row_aset['total'],0,',','.').",-"; $totawl +=$row_aset['total'];?></td>
            <td align="right"><?php $thnnow = date("Y"); $selisih = $thnnow - $row_aset['thn']; $aksusut = 0; for($ak=1;$ak<=$selisih;$ak++) { $nil = ($row_aset[bobot] / 100) * $row_aset[total];$aksusut += $nil;} $bulansusut = $aksusut / 12; echo number_format($bulansusut,0,',','.').",-";?></td>
            <td align="right"><?php if($aksusut > $row_aset[total]) { $aksusut = $row_aset[total];} echo number_format($aksusut,0,',','.').",-";$totsusut += $aksusut; $totbulan += $bulansusut;?></td>
            <td align="right"><?php if($row_aset['total'] - $aksusut > 0) { echo number_format($row_aset['total'] - $aksusut,0,',','.').",-";}else{ echo "0,00";} $totas += $row_aset['total'] - $aksusut;?></td>
          </tr>
          <?php } while ($row_aset = mysql_fetch_assoc($aset)); ?>
      <tr>
        <td align="right">&nbsp;</td>
          <td align="right">&nbsp;</td>
          <td align="right"><strong>Total : </strong></td>
          <td align="right"><?php echo number_format($totawl,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($totbulan,0,',','.').",-";?></td>
          <td align="right"><?php echo number_format($totsusut,0,',','.').",-";?></td>
        <td align="right"><?php echo number_format($totas,0,',','.').",-";?></td>
      </tr>
            </table></td>
  </tr>
    <?php }else{ ?>
  <tr>
    <td>Data Aset tidak ada !!! </td>
  </tr>
    <?php //} ?>
  <?php } ?>
  <tr>
    <td></td>
  </tr>
</table>
<?php
mysql_free_result($aset);
?>
